<?php 

$sql = "
SELECT
		B.TABLE_NAME			AS TABLE_NAME,
		B.CONSTRAINT_NAME		AS INDEX_NAME,
		B.ORDINAL_POSITION		AS COLUMN_POSITION,	
		B.COLUMN_NAME			AS COLUMN_NAME,
		''						AS DESCEND,
		''						AS UQ,
		(
			select case when count(*) > 1 then 'PK' else '' end  as f 
			from INFORMATION_SCHEMA.TABLE_CONSTRAINTS
			where CONSTRAINT_NAME = B.CONSTRAINT_NAME AND CONSTRAINT_TYPE = 'PRIMARY KEY'
		)	as PK
FROM 
	 INFORMATION_SCHEMA.KEY_COLUMN_USAGE B
where 
	B.TABLE_SCHEMA = '{$param['schema']}' and B.TABLE_NAME = '{$param['object']}'
order by 
	B.ORDINAL_POSITION
";

return $sql;

?>